home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / LinkList / c / AddToHead next >
Text File  |  1995-07-08  |  1KB  |  37 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    LinkList.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.02 (16 Mar 1992)
  14.     Purpose: Linked list handling functions
  15. */
  16.  
  17.  
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20.  
  21. #include "DeskLib:LinkList.h"
  22.  
  23. extern void LinkList_AddToHead(linklist_header *anchor, linklist_header *item)
  24. {
  25.   linklist_header *oldfirst;
  26.  
  27.   oldfirst       = anchor->next;
  28.   item->next     = oldfirst;                                /* link in next  */
  29.   item->previous = NULL;                                    /* First in list */
  30.  
  31.   if (oldfirst == NULL)
  32.     anchor->previous = item;              /* First item, so it is 1st & last */
  33.   else
  34.     oldfirst->previous = item;                              /* reverse link  */
  35.   anchor->next = item;                                      /* forward link  */
  36. }
  37.